package com.gaga.console.core.controller.bv;


import com.gaga.common.enums.LiveRoomStatusType;
import com.gaga.common.enums.PlayerType;
import com.gaga.common.path.ApiPath;
import com.gaga.common.result.Result;
import com.gaga.console.base.controller.BaseController;
import com.gaga.console.core.entity.dto.BatchTtsDto;
import com.gaga.console.core.entity.dto.SwitchModelDto;
import com.gaga.console.core.service.BvAudioPlayService;
import com.gaga.console.core.service.BvModelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户信息表 前端控制器
 *
 * @author liujia
 * @since 2025-03-27
 */
@RestController
@RequestMapping(ApiPath.ROOT + "/bv/model")
public class BvModelController extends BaseController {
    @Autowired
    private BvModelService bvModelService;
    @Autowired
    private BvAudioPlayService bvAudioPlayService;

    @ApiOperation(value = "获取模型列表")
    @PostMapping("/listModel")
    public Result listModel() {
        return Result.ok(bvModelService.listModel());
    }

    @ApiOperation(value = "切换模型")
    @PostMapping("/switchModel")
    public Result switchModel(@RequestBody SwitchModelDto dto) {
        PlayerType playerType = PlayerType.getPlayerTypeByCode(dto.getPlayerType());
        bvModelService.switchModel(playerType, dto.getModelName());
        return Result.ok();
    }

    @ApiOperation(value = "文本转语音")
    @PostMapping(value = "/batchTts")
    public Result batchTts(@RequestBody BatchTtsDto dto) {
        bvModelService.batchTts(dto);
        return Result.ok();
    }


    @ApiOperation(value = "重启模型--模型接口不支持")
    @PostMapping("/restartModel")
    @Deprecated
    public Result switchModel() {
        bvModelService.restartModel();
        return Result.ok();
    }

    @ApiOperation(value = "退出模型--模型接口不支持")
    @PostMapping("/exitModel")
    @Deprecated
    public Result exitModel() {
        bvModelService.exitModel();
        return Result.ok();
    }

    @ApiOperation(value = "切换模型")
    @PostMapping("/testListening")
    public Result testListening(@RequestBody SwitchModelDto dto) throws Exception {
        PlayerType playerType = PlayerType.getPlayerTypeByCode(dto.getPlayerType());
        bvModelService.testListening(playerType, dto.getModelName());
        return Result.ok();
    }

    @ApiOperation(value = "获取直播间状态")
    @PostMapping("/getLiveStatus")
    public Result getLiveStatus() {
        return Result.ok(bvAudioPlayService.getLiveRoomStatus());
    }

    @ApiOperation(value = "更新直播间状态")
    @PostMapping("/setLiveStatus/{liveRoomStatusType}")
    public Result setLiveStatus(@PathVariable LiveRoomStatusType liveRoomStatusType) {
        bvAudioPlayService.setLiveStatus(liveRoomStatusType);
        return Result.ok();
    }


}
